package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {
    @Autowired
    private GeofenceService geofenceService;

    @GetMapping("/select")
    public JsonResult select(GeofenceQuery geofenceQuery) {
        log.debug("查询电子围栏-入参：{}", geofenceQuery);
        log.debug("查询电子围栏-geofenceService-入参：{}", geofenceQuery);
        List<GeofenceVO> geofenceVOList = geofenceService.selectGeofence(geofenceQuery);
        log.debug("查询电子围栏-geofenceService-入参:{},出参：{}", geofenceQuery,geofenceVOList);
        JsonResult result = JsonResult.ok(geofenceVOList);
        log.debug("查询电子围栏-入参:{},出参:{}", geofenceQuery, result);
        return result;
    }

    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Long id) {
        log.debug("删除电子围栏-入参：{}", id);
        log.debug("删除电子围栏-geofenceService-入参：{}", id);
        Boolean result = geofenceService.deleteGeofence(id);
        log.debug("删除电子围栏-geofenceService-入参:{},出参：{}", id,result);
        JsonResult jsonResult = JsonResult.ok(result);
        log.debug("删除电子围栏-入参:{},出参:{}", id, jsonResult);
        return jsonResult;
    }

}
